<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/11/9
 * Time: 13:46
 */

namespace app\modules\singleton\controller;

use app\modules\singleton\Singleton;
use yii\web\Controller;

/**
 * Class DefaultController
 * @package app\modules\singleton\controller
 */
class DefaultController extends Controller
{
    /**
     * 单例模式示例
     * 在应用程序调用的时候，只能获得一个对象实例。(例如数据库连接)
     *
     * @date   2018/11/9
     * @author edmmss
     * @return int
     */
    public function actionIndex()
    {
        $firstInstantiation = Singleton::getInstance();
        var_dump($firstInstantiation);
        $secondInstantiation = Singleton::getInstance();
        var_dump($secondInstantiation);

        return 12;
    }
}